import { defineStore } from 'pinia'

import defaultSettings from '@/settings'

interface SettingsState {
	isCollapse: boolean
	sidebarLogo: boolean
	breadcrumb: boolean
}

export const useSettingsStore = defineStore('settings', {
	persist: true,
	state: (): SettingsState => ({
		// 折叠菜单
		isCollapse: false,
		sidebarLogo: defaultSettings.sidebarLogo,
		breadcrumb: defaultSettings.breadcrumb,
	}),
	getters: {},
	actions: {
		changeSetting(...args: ObjToKeyValArray<SettingsState>) {
			this.$patch({ [args[0]]: args[1] })
		},
	},
})
